import axios from 'axios' //引用axios

axios.defaults.timeout = 5000;
axios.defaults.withCredentials = true

export default axios;

export function getMethod(url, params) {
    return axios({
        url: url,
        method: 'get',
        params: params
    })
}

export function postMethod(url, params) {
    var formData = new FormData();
    if (params != null)
        for (var key in params) {
            if (params[key] != null)
                formData.append(key, params[key])
        }
    return axios.post(url, formData)
}